<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

use EasyWeChat\Foundation\Application;

class Wechat {

    private $_CI;
    private $_sessionUserKey = 'wechat_user';

    public function __construct()
    {
        $this->_CI =& get_instance();
    }

    /**
     * 微信登录验证
     * @param  string $action 回调的action
     * @return void
     */
    public function oauth($con,$func) {
        // 未登录
        if (!$this->_CI->session->has_userdata("wechat_user")) {
            $config = [
                'app_id' => "wx6e388c39c223c15a",//$this->_CI->config->item("app_id"),
                'oauth' => [
                    'scopes'   => ['snsapi_base'], //snsapi_userinfo
                    'callback' => 'index.php/'.$con.'/wechatOauthBack',
                ],
            ];
            $app = new Application($config);
            $oauth = $app->oauth;
            $this->_CI->session->set_userdata('target_url', 'index.php/'.$con."/".$func);
            $oauth->redirect()->send();
        }
    }
}

/* End of file AvatarResize.php */
/* Location: ./application/libraries/AvatarResize.php */
